function doImage(obj){
		var img = $(obj).prev();
		var ret = toBase64(obj, function(data) {
			img.attr("src", data);
			$(obj).prev().prev().val(data);
		});
		if(!ret){
			$(obj).val("");
		}
}



function doFile(obj) {
	var now_type = $("#now_type").val();
    var fileObj = document.getElementById("filename").files; // js 获取文件对象
    if(fileObj.length==0){
        errorAlert('请选择文件');
        return;
    }
    var formFile = new FormData();
    for (var i = 0; i <fileObj.length; i++) {
        formFile.append("myfile[]", fileObj[i]); //加入文件对象
    }

    var data = formFile;
    setTimeout(function() {
        $.ajax({
            url: 'Admin/CommonUpload/UploadFile/' + now_type,
            data: data,
            type: "POST",
            dataType: "json",
            cache: false, //上传文件无需缓存
            processData: false, //用于对data参数进行序列化处理 这里必须false
            contentType: false, //必须
            xhr: xhrOnProgress(function(e) {
                var percent = e.loaded / e.total;
                var now_jindu = (parseFloat(percent) * 100).toFixed(2);
               // console.log(now_jindu);

            }),
            success: function(data) {
                if (data.status) {
                    // alert(now_type);
                    var path=JSON.parse(data.v);
                    var icon=JSON.parse(data.remark);
                    $.each(path,function(k,v){
                    	//console.log(v);
                    	$("#files").val(v);

                    	strs = v.split("/"); //字符分割
                    	var strs1 = strs[3];

                    	strs2 = strs1.split(")"); 

                    	//console.log(strs2);

                    	$(".showFileName").html(strs2[1]);

                    	$(".icon-remove-sign").show();

                    }); 
                } else {
                    window.parent.topMessagePrompt('error', data.msg);
                }
            }
        })
    }, 1000);
}


var xhrOnProgress = function(fun) {
    xhrOnProgress.onprogress = fun; //绑定监听
    //使用闭包实现监听绑
    return function() {
        //通过$.ajaxSettings.xhr();获得XMLHttpRequest对象
        var xhr = $.ajaxSettings.xhr();
        //判断监听函数是否为函数
        if (typeof xhrOnProgress.onprogress !== 'function')
            return xhr;
        //如果有监听函数并且xhr对象支持绑定时就把监听函数绑定上去
        if (xhrOnProgress.onprogress && xhr.upload) {
            xhr.upload.onprogress = xhrOnProgress.onprogress;
        }
        return xhr;
    }
}



//删除文件
function delDocument(obj) {
    $(obj).parents('.data-box').remove();

    // console.log($(obj).parents('.data-box'));


	$(".showFileName").html('');
	// $(".icon-remove-sign").hide();
	$("#files").val('');
}